package com.lezhi.socialgram.model.moments;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lezhi.socialgram.annotation.Table;
import com.lezhi.socialgram.util.JsonUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;

import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * Created by daizhen on 2017/4/1.
 */
@Table(prefix = "t_moments_")
@Document(indexName = "social_gram_moments", type = "moment", createIndex = false)
public class Moment {

    @Field(ignoreFields = "table")
    private String table;

    private String likedFansIds;

    @Id
    private String momentId;

    @NotNull(message = "媒体类型不能为空")
    private Integer mediaType;

    @NotNull(message = "发布者id不能为空")
    private Long userId;

    @NotNull(message = "媒体列表不能为空")
    private List<Media> media_list;

    @Field(ignoreFields = "mediaUrlList")
    private String mediaUrlList;

    private String textContent;

    private List<String> subject_list;

    @Field(ignoreFields = "subjectList")
    private String subjectList;

    private List<Long> atSomeOne_list;

    @Field(ignoreFields = "atSomeOneList")
    private String atSomeOneList;

    private String location;

    @NotNull(message = "纬度不能为空")
    private Double lat;

    @NotNull(message = "经度不能为空")
    private Double lon;

    private Integer isPublic;

    private Integer price;

    @Field(ignoreFields = "createTime")
    private Date createTime;

    private Long createTimezone;

    private Integer onTheTop;

    public Moment() {
    }

    public Moment(String table, Long userId) {
        this.table = table;
        this.userId = userId;
    }

    @JsonIgnore
    public String getTable() {
        return table;
    }

    public void setTable(String table) {
        this.table = table;
    }

    @JsonIgnore
    public String getLikedFansIds() {
        return likedFansIds;
    }

    public void setLikedFansIds(String likedFansIds) {
        this.likedFansIds = likedFansIds;
    }

    public String getMomentId() {
        return momentId;
    }

    public void setMomentId(String momentId) {
        this.momentId = momentId;
    }

    public Integer getMediaType() {
        return mediaType;
    }

    public void setMediaType(Integer mediaType) {
        this.mediaType = mediaType;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public List<Media> getMedia_list() {
        return media_list;
    }

    public void setMedia_list(List<Media> media_list) {
        this.media_list = media_list;
    }

    public List<String> getSubject_list() {
        return subject_list;
    }

    public void setSubject_list(List<String> subject_list) {
        this.subject_list = subject_list;
    }

    public List<Long> getAtSomeOne_list() {
        return atSomeOne_list;
    }

    public void setAtSomeOne_list(List<Long> atSomeOne_list) {
        this.atSomeOne_list = atSomeOne_list;
    }

    @JsonIgnore
    public String getMediaUrlList() {
        return JsonUtils.objectToJson(media_list);
    }

    public void setMediaUrlList(String mediaUrlList) {
        this.media_list = JsonUtils.jsonToList(mediaUrlList, Media.class);
    }

    public String getTextContent() {
        return textContent;
    }

    public void setTextContent(String textContent) {
        this.textContent = textContent;
    }

    @JsonIgnore
    public String getSubjectList() {
        return JsonUtils.objectToJson(subject_list);
    }

    public void setSubjectList(String subjectList) {
        this.subject_list = JsonUtils.jsonToList(subjectList, String.class);
    }

    @JsonIgnore
    public String getAtSomeOneList() {
        return JsonUtils.objectToJson(atSomeOne_list);
    }

    public void setAtSomeOneList(String atSomeOneList) {
        this.atSomeOne_list = JsonUtils.jsonToList(atSomeOneList, Long.TYPE);
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public Double getLon() {
        return lon;
    }

    public void setLon(Double lon) {
        this.lon = lon;
    }

    public Integer getIsPublic() {
        return isPublic;
    }

    public void setIsPublic(Integer isPublic) {
        this.isPublic = isPublic;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getCreateTimezone() {
        return createTimezone;
    }

    public void setCreateTimezone(Long createTimezone) {
        this.createTimezone = createTimezone;
    }

    public Integer getOnTheTop() {
        return onTheTop;
    }

    public void setOnTheTop(Integer onTheTop) {
        this.onTheTop = onTheTop;
    }

    @Override
    public String toString() {
        return "Moment{" +
                "mediaType=" + mediaType +
                ", userId=" + userId +
                ", media_list=" + media_list +
                ", mediaUrlList='" + mediaUrlList + '\'' +
                ", textContent='" + textContent + '\'' +
                ", subject_list=" + subject_list +
                ", subjectList='" + subjectList + '\'' +
                ", atSomeOne_list=" + atSomeOne_list +
                ", atSomeOneList='" + atSomeOneList + '\'' +
                ", location='" + location + '\'' +
                ", lat=" + lat +
                ", lon=" + lon +
                ", isPublic=" + isPublic +
                ", price=" + price +
                '}';
    }
}
